/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models;
import cstAndEnum.*;
import java.util.ArrayList;
import java.util.List;
import models.Deck.*;


/**
 *玩家
 * @author Invince
 */
public class Player {
/*----------Attributs-------------------*/
    /**
     * 玩家id
     */
    protected int id;
    /**
     * 玩家名字
     */
    protected String name;
    /**
     * 玩家身份：主公MAJESTY，忠臣LOYAL，反贼REBEL，内奸SPY
     */
    protected CARA cara;
    /**
     * 玩家铁索状态
     */
    protected STATE_CHAIN stateChain;
    /**
     * 玩家持有的牌
     */
    protected DeckPlayer deckPlayer;//Deck id=1
    /**
     * 玩家的装备库
     */
    protected DeckEquipement deckEqp;//Deck id=2
    /**
     * 需要判定的牌
     */
    protected DeckBuff deckBuff;//Deck id=3
    /**
     * 武将
     */
    protected Role role;
    /**
     * 传输相关
     **/
    protected PlayerConnection connection;
    /**
     * 选择武将时发的武将牌（建游戏时用）
     */
    protected List<Role> roleSelect;
    /**
     * 是否是主机
     */
     protected boolean isServer;
/*----------Public functions------------*/
    /**
     * 判断玩家是否相等（只有类型和名字）
     * @param obj
     * @return
     */
   @Override
   public boolean equals(Object obj){
       if (obj == null){
           return false;
       }
       if (obj == this){
           return true;
       }
       if (!obj.getClass().equals(this.getClass())) {
           return false;
       } else {
           Player pObj = (Player)obj;
           return (pObj.id==(this.id));
       }
   }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 19 * hash + this.id;
        return hash;
    }

   

/*----------Private functions-----------*/
/*----------Constructor-----------------*/
    /**
     * 临时玩家列表专用
     * @param name
     * @param connection
     */
    public Player(int id,String name, PlayerConnection connection) {
        this.id=id;
        this.name = name;
        this.connection = connection;
        this.roleSelect=new ArrayList<Role>();
    }

    /**
     * 建立游戏时用，不过似乎一般用不着（因为一般都是临时玩家列表，然后setCarac的）
     * @param name
     * @param carac
     */
    public Player(int id,String name, CARA cara) {
       this.id=id;
       this.name = name;
       this.cara = cara;
       this.isServer=false;
       this.roleSelect=new ArrayList<Role>();
       // 需不需要建出牌库来
   }

   public Player(int id,String name, CARA cara,PlayerConnection connection) {
       this(id,name,cara);
       this.connection=connection;
       this.isServer=false;
       this.roleSelect=new ArrayList<Role>();
       // 需不需要建出牌库来
   }

/*----------Gets and sets---------------*/
   public CARA getCara() {
       return cara;
   }

   public void setCara(CARA cara) {
       this.cara = cara;
   }

   public DeckBuff getDeckBuff() {
       return deckBuff;
   }

   public void setDeckBuff(DeckBuff deckBuff) {
       this.deckBuff = deckBuff;
   }

   public DeckEquipement getDeckEqp() {
       return deckEqp;
   }

   public void setDeckEqp(DeckEquipement deckEqp) {
       this.deckEqp = deckEqp;
   }

   public DeckPlayer getDeckPlayer() {
       return deckPlayer;
   }

   public void setDeckPlayer(DeckPlayer deckPlayer) {
       this.deckPlayer = deckPlayer;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public Role getRole() {
       return role;
   }

   public void setRole(Role role) {
       this.role = role;
   }

   public STATE_CHAIN getStateChain() {
       return stateChain;
   }

   public void setStateChain(STATE_CHAIN stateChain) {
       this.stateChain = stateChain;
   }

    public PlayerConnection getConnection() {
        return connection;
    }

    public void setConnection(PlayerConnection connection) {
        this.connection = connection;
    }

    public List<Role> getRoleSelect() {
        return roleSelect;
    }

    public void setRoleSelect(List<Role> roleSelect) {
        this.roleSelect = roleSelect;
    }

    public boolean isIsServer() {
        return isServer;
    }

    public void setIsServer(boolean isServer) {
        this.isServer = isServer;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
}
